package com.zfl.thread.day04;

public class ThreadLocalDemo02 {

    public static ThreadLocal<Integer> threadLocal= ThreadLocal.withInitial(()->0);

    public static void main(String[] args) {

        for (int i = 0; i < 10; i++) {
            final int N=i;
            new Thread(()->{
                threadLocal.set(threadLocal.get()+N);

                System.out.println(Thread.currentThread().getName()+" - "+threadLocal.get() );
            }).start();
        }


    }


}
